package com.demo.exception;

public class ExceptionMessage {
	
	/**
     * 获取异常出错详细信息
     * @param objectException 异常类对象
     * @return
     */
    public String getExceptionDetail(Object objectException){
    	StringBuffer msg = new StringBuffer("null"); 
		Exception exception = (Exception)objectException; 
		if (exception != null) {
			msg = new StringBuffer(""); 
			String message = exception.toString(); 
			int length = exception.getStackTrace().length; 
			if (length > 0) { 
				msg.append(message + "\n"); 
				for (int i = 0; i < length; i++) { 
					msg.append("\t" + exception.getStackTrace()[i] + "\n"); 
				}
			} else { 
				msg.append(message);
			} 
		}
		
		return  msg.toString();
	}
}
